package com.java.wmovie.config;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class AdminInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object admin =  request.getSession().getAttribute("loginAdmin");
        if (admin == null) {
            request.getRequestDispatcher("/ALogin").forward(request, response);
            return false;
        }
        return true;
    }
}
